package com.yhgm.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yhgm.model.entity.RolePermission;
import com.yhgm.model.entity.Roles;
import com.yhgm.service.RolePermissionService;
import com.yhgm.mapper.RolePermissionMapper;
import org.apache.commons.math3.analysis.function.Abs;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
* @author Gaoming
* @description 针对表【role_permission(角色权限对应表)】的数据库操作Service实现
* @createDate 2024-03-24 13:40:14
*/
@Service
public class RolePermissionServiceImpl extends ServiceImpl<RolePermissionMapper, RolePermission>
    implements RolePermissionService{

    @Resource
    private RolePermissionMapper rolePermissionMapper;
    @Override
    public List<Long> getPermissionByRoleId(Long id) {
        QueryWrapper<RolePermission> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq(id != null, "roleId", id);
        List<RolePermission> rolePermissionList = rolePermissionMapper.selectList(queryWrapper);
        List<Long> result = new ArrayList<>();
        for (RolePermission rolePermission : rolePermissionList) {
            result.add(rolePermission.getPermissionId());
        }
        return result;
    }
}




